import pymysql
import utils.PltUtil as plt

# 连接到数据库
conn = pymysql.connect(host='39.105.149.147', port=3306, user='root', password='haoserver121231', db='stock')

# 创建游标对象
cursor = conn.cursor()

# 执行SQL查询
cursor.execute(
    "select final_price from his_data where d_name = '300177' and d_date >= '2023-05-01' and d_date < '2023-11-22' ORDER BY d_date asc")

# 获取所有结果
results = cursor.fetchall()

# 打印结果
# for row in results:
#     print(row[0], '    ', row[1])

# 关闭游标对象
cursor.close()

# 关闭连接对象
conn.close()

plt.line_chart(range(0, len(results)), results)
